home *** CD-ROM | disk | FTP | other *** search
/ ASP Advantage 1993 / The Association of Shareware Professionals Advantage CD-ROM 1993.iso / files / commions / ca29_1 / ca29_3.exe / BBSETUP.CMD < prev    next >
OS/2 REXX Batch file  |  1992-03-24  |  28KB  |  953 lines

  1.     SET TTHRU OFF        ; Must be 1st line to suppress typethrough
  2.     LEGEND "BBS Setup ver 1.0"
  3. ;****    TRACE ON        ; Debugging
  4. ;
  5. ; ----- COM-AND BBS setup script
  6. ;    Commenced: 11/90 R.McG
  7. ; -----------------------------------------------------------------------
  8. ;    Purpose:
  9. ;       This script, named BBSETUP.CMD, is executed to setup the BBS
  10. ;    script (version 1.1).  Setup 1) identifies the port and modem
  11. ;    control values, 2) identifies (and creates) the subdirs to be
  12. ;    used.  The script BBMAINT is used to update related files.
  13. ; -----------------------------------------------------------------------
  14. ;    NOTE: This script expects to find a file named BBSDAT on 1) the
  15. ;    current subdirectory, 2) The COM-AND= environment var specified
  16. ;    subdirectory, or 3) the subdirectory where THIS script resides.
  17. ;    If this file is found, it will be overwritten subsequently.  If
  18. ;    NOT found, BBSDAT will be created on the subdir where COM-AND=
  19. ;    points.  S29 is used to keep the file name (subroutine INIT).
  20. ; -----------------------------------------------------------------------
  21. ;
  22. ;    Establish a DWINDOW, and change the text display to window default.
  23. ;    .. Save the previous text display attribute, for restoration later.
  24. ;
  25.     DWIND 1,2 22,78     ; Establish scrolling region
  26.     N99 = "_TEXT"           ; Save original text attr
  27.     SET TEXT "_DEFA"        ; Set text attr
  28.     SET FLAG(9) OFF     ; Note if we did any saves
  29. ;
  30. ;    Perform tasks
  31. ;
  32.     GOSUB Init        ; Setup initial values
  33.     GOSUB Main        ; Paint main screen
  34. ;***    GOSUB ChkSave        ; Check if save needed
  35.     GOSUB ChkAll        ; Check if subd's exist
  36. ;
  37. ;    Exit the script
  38. ;
  39. Escape:
  40. Exit:
  41.     SET TEXT N99        ; Reset text attr finally
  42.     DWINDOW CLEAR        ; Clear any scrolling region
  43.     CLEAR            ; Clear entire text window
  44.     EXIT
  45. ; -----------------------------------------------------------------------
  46. ; ----- Subroutine: Init ->  Set initial values from BBSDAT
  47. ;    .. NOTE: S29 returns the file name to use for writes to BBSDAT
  48. ;
  49. Init:
  50.     S20 = "_PARM"(11:14)*","*"_PARM"(0:3) ; Port(4),speed(4)
  51.     S21 = "ATE0Q0V1X1S0=2 S7=30 S9=10^M"  ; Standard MINIT for BBS
  52.     S22 = "\BBS"            ; Set to our subdirectory
  53.     S23 = "\BBS\FILES"      ; Set subdir for files
  54.     S24 = "\BBS\MAIL"       ; Set subdir for mail
  55.     S25 = "\BBS\BULLETIN"   ; Set subdir for bulletins
  56. ;
  57. ;    Replace above values from BBSDAT, if that script exists
  58. ;
  59.     S29 = ""                ; Make value null
  60.     IF ISSC "BBSDAT"        ; If file exists on dft subdir or COM-AND=
  61.        FCALL "BBSDAT"       ; .. execute it
  62.     ELSE
  63.        S10 = "_SCRIPT"      ; Get current script fname
  64.        GOSUB Parse_Fname    ; Extract drive:Subdir from name
  65.        S10 = S10*"\BBSDAT"  ; Make new name
  66.        IF ISSC S10        ; Invoke it if its THERE
  67.           FCALL S10     ; Invoke it
  68.           S29 = S10     ; Save for later
  69.           ENDIF
  70.        ENDIF
  71.     RETURN            ; Done init
  72. ; -----------------------------------------------------------------------
  73. ;    Subroutine: Parse drive:subdirectory from file name
  74. ;
  75. ;    S10 passes fully name        S10 returns drive:subdirectory
  76. ;                    S11 returns file name
  77. ;    N10,N11 are scratch values
  78. ; -----------------------------------------------------------------------
  79. ;
  80. Parse_Fname:
  81.     LENGTH S10 N10            ; Find length of string
  82.     FOR N11 = (N10-1),0,-1        ; Scan backwards through string
  83.         IF STRCMP S10(N11:N11) ":" or STRCMP S10(N11:N11) "\" GOTO PAFN100
  84.         ENDFOR
  85.     S11 = S10            ; No drive or path
  86.     S10 = ""                        ; Return null drive:path spec
  87.     RETURN
  88. ;
  89. ;    Extract drive and path from name; N11 points to ":" or "\"
  90. ;
  91. PAFN100:
  92.     S11 = S10(N11+1:N10)        ; Extract name portion
  93.     IF STRCMP S10(N11:N11) "\" DEC N11
  94.     S10 = S10(0:N11)        ; Save ":", remove last "\"
  95.     RETURN
  96. ; -----------------------------------------------------------------------
  97. ; ----- Subroutine: Save -> Save values in BBSDAT
  98. ;    .. BBSDAT is placed in dft subdir; create file if need be
  99. ;
  100. Save:
  101.     IF NULL S29        ; If INIT did not set a name
  102.     ;
  103.     ; Construct a file name on the appropriate directory
  104.     ;
  105.        S1 = ""              ; Initialize file name string
  106.        IF NOT ISFIL "BBSDAT"; If not on current subdir
  107.           ENVIRON S1 "COM-AND="; Look for COM-AND= environment var
  108.           IF FOUND        ; If environment variable found
  109.          LENGTH S1 N0    ; Get its length
  110.          N0 = N0-1    ; Point to last char in string
  111.          IF not STRCMP S1(n0:n0) "\"
  112.             N0 = N0+1    ; Point after last char
  113.             CONCAT S1(n0) "\"
  114.             ENDIF
  115.          ENDIF
  116.           ENDIF
  117.        S1 = S1&"BBSDAT"     ; Add the necessary file name
  118.     ELSE S1 = S29        ; Else use name set by INIT
  119.     ;
  120.     ; Open the file, write the file, and close it
  121.     ;
  122.     FOPENO S1 TEXT        ; Open the file name so constructed
  123.     IF NOT SUCCESS
  124.        S0 = "Error opening BBSDAT file: "*S1
  125.        GOSUB Error        ; Report
  126.        RETURN        ; And we're done
  127.        ENDIF
  128.        S29 = "_OFILE"           ; Save file name we opened
  129.        ;
  130.        ; Write values we have as of now
  131.        ;
  132.     WRITE "; --- BBS initialization !" ; Write initial comments
  133.     WRITE ";     Updated "*"_DATE"*", at "*"_TIME"*"!"
  134.     WRITE ";!"                         ; Write initial comments
  135.  
  136.     WRITE "S20=`""*S20&"`"!"    ; Write port and speed
  137.     S0 = S21        ; Copy control string
  138.     PRESERVE S0        ; Make it printable
  139.     WRITE "S21=`""*S0&"`"!" ; Write modem control string
  140.     WRITE "S22=`""*S22&"`"!"; Write BBS subdir
  141.     WRITE "S23=`""*S23&"`"!"; Write BBS files subdir
  142.     WRITE "S24=`""*S24&"`"!"; Write BBS mail subdir
  143.     WRITE "S25=`""*S25&"`"!"; Write BBS bulletin subdir
  144.     WRITE "FRETURN!^Z "     ; Write end of file
  145.        ;
  146.        ; Close the file and we're done
  147.        ;
  148.     SET FLAG(9) ON        ; Note we did ONE save
  149.     FCLOSEO         ; Close the file
  150.     RETURN            ; And we're done
  151. ; -----------------------------------------------------------------------
  152. ; ----- Error:    Open a window, display a message, and wait for keypress
  153. ;    S0 passes the error message
  154. ;
  155. Error:
  156.     WOPEN 10,10,12,70 (cont) Err_Esc
  157.     ATSAY 10,12 (cont) " Error "
  158.     ATSAY 11,12 (cont) S0(0:55); Max msg width 55 chars
  159.     ATSAY 12,26 (cont) " Press any key to continue "
  160.     ;
  161.     ;    Wait a keypress
  162.     ;
  163.     KEYGET S0        ; Wait for any key
  164.     WCLOSE
  165. Err_Esc:
  166.     RETURN
  167. ; -----------------------------------------------------------------------
  168. ; ----- Subroutine: ChkSave ->    Save file?
  169. ;
  170. ChkSave:
  171.     IF FLAG(9) RETURN    ; At least one save was performed
  172.     WOPEN 0,0 23,79 (defa) Main_ESC
  173.     ATSAY 0,2 (defa)   " BBS Save "
  174.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  175. CHSA100:
  176.     CLEAR            ; Clear window
  177.     LOCATE 2,2
  178.     MESS " Do you wish to save the current values? (y/n) "
  179.     MESS "──────────────────────────────────── "
  180.     MESS "    Port and speed  is: "*S20
  181.     S0 = S21        ; Copy control string
  182.     PRESERVE S0        ; Make it printable
  183.     MESS "    Modem control   is: "*S0
  184.     MESS "    BBS main subdir is: "*S22
  185.     MESS "    Files subdir    is: "*S23
  186.     MESS "    Mail subdir     is: "*S24
  187.     MESS "    Bulletin subdir is: "*S25
  188.     MESS " "
  189.     MESS "──────────────────────────────────── "
  190.     MESS "Enter y or n (carriage return = n): "
  191. ;
  192. ;    Wait for a keypress
  193. ;
  194.     GET S0 1        ; Wait for it
  195.     IF NULL S0 GOTO CHSA200 ; If c/r, simply return
  196.     SWITCH S0        ; Act according to keyget
  197.       CASE "y"              ; Case insensitive
  198.            GOSUB Save
  199.            GOTO CHSA200
  200.            ENDCASE
  201.       CASE "n"              ; Case insensitive
  202.            GOTO CHSA200
  203.            ENDCASE
  204.       DEFAULT        ; None of the above
  205.            SOUND 100,100    ; Bronx cheer
  206.            ENDCASE
  207.       ENDSWITCH
  208.     GOTO CHSA100        ; Repaint screen and ask again
  209. ;
  210. ;    Exit, closing the window
  211. ;
  212. CHSA200:
  213.     WCLOSE
  214.     RETURN
  215. ; -----------------------------------------------------------------------
  216. ; ----- Subroutine: ChkAll ->  Check for subdir creation req'd
  217. ;
  218. ChkAll:
  219.     WOPEN 10,10 12,70 (cont)
  220.     ATSAY 10,12 (cont)   " BBS Subdirs "
  221.     ATSAY 11,12 (cont) " Checking existance of subdirs... "
  222.     PAUSE 1         ; Make it visible
  223. ;
  224. ;    Test for the existence of all subdirectories
  225. ;
  226.     SET FLAG(0) ON
  227.     FFIRST S22&"\*.*"       ; test for Main subd
  228.     IF SUCCESS SET FLAG(0) OFF
  229.  
  230.     SET FLAG(1) ON
  231.     FFIRST S23&"\*.*"       ; test for File subd
  232.     IF SUCCESS SET FLAG(1) OFF
  233.  
  234.     SET FLAG(2) ON
  235.     FFIRST S24&"\*.*"       ; test for Mail subd
  236.     IF SUCCESS SET FLAG(2) OFF
  237.  
  238.     SET FLAG(3) ON
  239.     FFIRST S25&"\*.*"       ; test for Main subd
  240.     IF SUCCESS SET FLAG(3) OFF
  241.  
  242.     WCLOSE            ; Close window we opened
  243.     IF NOT (FLAG(0) or FLAG(1) or FLAG(2) or FLAG(3)) RETURN
  244. ;
  245. ;    Ask if we're to create subdirs
  246. ;
  247.     WOPEN 0,0 23,79 (defa) Main_ESC
  248.     ATSAY 0,2 (defa)   " BBS Subdirs "
  249.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  250. ;
  251. ;    Display subdirs that do not exist
  252. ;
  253. CHAL100:
  254.     CLEAR            ; Clear window
  255.     LOCATE 2,2
  256.  
  257.     IF FLAG(0) MESS S22&" does not exist"
  258.     IF FLAG(1) MESS S23&" does not exist"
  259.     IF FLAG(2) MESS S24&" does not exist"
  260.     IF FLAG(3) MESS S25&" does not exist"
  261.     MESS " "                ; Blank separator
  262.     MESS " Do you wish to create the missing subdirs? (y/n) "
  263.     MESS "──────────────────────────────────── "
  264.     MESS " "
  265.     MESS "Enter y or n (carriage return = n): "
  266. ;
  267. ;    Wait for a keypress
  268. ;
  269.     GET S0 1        ; Wait for it
  270.     IF NULL S0 GOTO CHAL200 ; If c/r, simply return
  271.     SWITCH S0        ; Act according to keyget
  272.       CASE "y"              ; Case insensitive
  273.            GOSUB CreateSd
  274.            GOTO CHAL200
  275.            ENDCASE
  276.       CASE "n"              ; Case insensitive
  277.            GOTO CHAL200
  278.            ENDCASE
  279.       DEFAULT        ; None of the above
  280.            SOUND 100,100    ; Bronx cheer
  281.            ENDCASE
  282.       ENDSWITCH
  283.     GOTO CHAL100        ; Repaint screen and ask again
  284. ;
  285. ;    Exit, closing the window
  286. ;
  287. CHAL200:
  288.     WCLOSE
  289.     RETURN
  290. ; -----------------------------------------------------------------------
  291. ; ----- Subroutine: Main ->  main menu
  292. ;
  293. Main:
  294.     WOPEN 0,0 23,79 (defa) Main_ESC
  295.     ATSAY 0,2 (defa)   " BBS Setup "
  296.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  297. ;
  298. ;    Paint the menu
  299. ;
  300. Main100:
  301.     CLEAR            ; Clear window
  302.     LOCATE 2,2
  303.     MESS " 1) Identify subdirectories used by BBS;      Do this 1st!!"
  304.     MESS " 2) Create BBS subdirectories and files;      Do this 2nd!!"
  305.     MESS " 3) Identify modem values;                    Finally..."
  306.  
  307.     IF ISSCRIPT "BBMaint" MESS " 4) Invoke maintenance script"
  308.     IF ISSCRIPT "BBS"     MESS " 5) Invoke the BBS"
  309.  
  310.     MESS "──────────────────────────────────── "
  311.     MESS "    Port and speed  is: "*S20
  312.     S0 = S21        ; Copy control string
  313.     PRESERVE S0        ; Make it printable
  314.     MESS "    Modem control   is: "*S0
  315.     MESS "    BBS main subdir is: "*S22
  316.     MESS "    Files subdir    is: "*S23
  317.     MESS "    Mail subdir     is: "*S24
  318.     MESS "    Bulletin subdir is: "*S25
  319.     MESS " "
  320.     MESS "──────────────────────────────────── "
  321.     MESS "BBSMAINT is used to update files once you have SETUP"
  322.     MESS " "
  323.     MESS "──────────────────────────────────── "
  324.     MESS "Select item (carriage return = exit): "
  325. ;
  326. ;    Wait for a keypress
  327. ;
  328.     GET S0 1        ; Wait for it
  329.     SWITCH S0        ; Act according to keyget
  330.       CASE "1"
  331.            GOSUB Subdirs
  332.            ENDCASE
  333.       CASE "2"
  334.            GOSUB ChkAll
  335.            ENDCASE
  336.       CASE "3"
  337.            GOSUB Modem
  338.            ENDCASE
  339.       CASE "4"
  340.            IF ISSCRIPT "BBMaint"
  341.           WCLOSE          ; Close open window
  342.           SET TEXT N99          ; Reset text attr finally
  343.           DWINDOW CLEAR       ; Clear any scrolling region
  344.           CLEAR           ; Clear entire text window
  345.           EXECUTE "BBMaint"       ; Chain to it
  346.           ENDIF
  347.            ENDCASE
  348.       CASE "5"
  349.            IF ISSCRIPT "BBS"
  350.           WCLOSE          ; Close open window
  351.           SET TEXT N99          ; Reset text attr finally
  352.           DWINDOW CLEAR       ; Clear any scrolling region
  353.           CLEAR           ; Clear entire text window
  354.           EXECUTE "BBS"           ; Chain to it
  355.           ENDIF
  356.            ENDCASE
  357.       CASE "_NULL"          ; c/r alone is exit
  358.            WCLOSE        ; Close window...
  359.            RETURN        ; Leave Main routine
  360.            ENDCASE
  361.       DEFAULT        ; None of the above
  362.            SOUND 100,100    ; Bronx cheer
  363.            ENDCASE
  364.       ENDSWITCH
  365.     GOTO Main100        ; Repaint screen and ask again
  366. ; -----------------------------------------------------------------------
  367. ; ----- Subroutine: Modem ->  modem values
  368. ;
  369. Modem:
  370.     WOPEN 0,0 23,79 (defa) Main_ESC
  371.     ATSAY 0,2 (defa)   " BBS Modem "
  372.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  373. ;
  374. ;    Paint the menu
  375. ;
  376. MODE100:
  377.     CLEAR            ; Clear window
  378.     LOCATE 2,2
  379.     MESS " 1) Identify modem port"
  380.     MESS " 2) Identify modem speed"
  381.     MESS " 3) Identify modem control string"
  382.     MESS "──────────────────────────────────── "
  383.     MESS "    Port and speed  is: "*S20
  384.     S0 = S21        ; Copy control string
  385.     PRESERVE S0        ; Make it printable
  386.     MESS "    Modem control   is: "*S0
  387.     MESS " "
  388.     MESS "──────────────────────────────────── "
  389.     MESS "Select item (carriage return = previous): "
  390. ;
  391. ;    Wait for a keypress
  392. ;
  393.     GET S0 1        ; Wait for it
  394.     SWITCH S0        ; Act according to keyget
  395.       CASE "1"
  396.            GOSUB Modem_Port
  397.            ENDCASE
  398.       CASE "2"
  399.            GOSUB Modem_Speed
  400.            ENDCASE
  401.       CASE "3"
  402.            GOSUB Modem_Control
  403.            ENDCASE
  404.       CASE "_NULL"          ; c/r alone is exit
  405.            WCLOSE        ; Close window...
  406.            RETURN        ; Leave Main routine
  407.            ENDCASE
  408.       DEFAULT        ; None of the above
  409.            SOUND 100,100    ; Bronx cheer
  410.            ENDCASE
  411.       ENDSWITCH
  412.     GOTO MODE100        ; Repaint screen and ask again
  413. ;
  414. ;    Escape during main
  415. ;
  416. Main_Esc:
  417.     S0 = ""                 ; Blank entry
  418.     RETURN            ; And execute it
  419. ;
  420. ; ----- Subroutine: Modem_port -> Set default modem port to use
  421. ;
  422. Modem_Port:
  423.     WOPEN 0,0 23,79 (defa) Main_ESC
  424.     ATSAY 0,2 (defa)   " BBS Port "
  425.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  426.     LOCATE 2,2
  427.  
  428.     MESS "The BBS is currently directed to run on the port: "*S20(0:3)
  429.     MESS " "
  430.     MESS "The BBS may use any port COM1 through COM4.  If you wish to use a port other"
  431.     MESS "than the above, enter it here."
  432.     MESS " "
  433.     MESS "Port (carriage rtn alone accepts): "
  434. ;
  435. ;    Wait for entry, and interpret
  436. ;
  437.     S0 = "    "             ; Default value
  438.     GET S0 4        ; Wait for a char
  439.     IF NULL S0 GOTO MOPOEND ; Nothing entered
  440.     IF NOT FIND S0(0:2) "com" GOTO MOPOERR
  441.     IF S0(3) LT 1 or S0(3) GT 4 GOTO MOPOERR
  442. ;
  443. ;    Save the value
  444. ;
  445.     S20(0:3) = S0        ; Set new value
  446.     GOSUB Save        ; Save the new value
  447. ;
  448. ;    End of window
  449. ;
  450. MOPOEND:
  451.     WCLOSE
  452.     RETURN
  453. ;
  454. ;    Error in input string
  455. ;
  456. MOPOERR:
  457.     SOUND 100,100        ; Bronx cheer
  458.     GOTO Modem_Port     ; And try again
  459. ;
  460. ; ----- Subroutine: Modem_Speed -> Set default modem speed to use
  461. ;
  462. Modem_Speed:
  463.     WOPEN 0,0 23,79 (defa) Main_Esc
  464.     ATSAY 0,2 (defa)   " BBS Speed "
  465.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  466.     LOCATE 2,2
  467.  
  468.     MESS "The BBS currently defaults to wait for call at: "*S20(5:8)*" baud"
  469.     MESS " "
  470.     MESS "The BBS may wait for a call at any rate you wish.  If you wish to use a "
  471.     MESS "speed other than the above, enter it here. Legitimate speeds are: 300,"
  472.     MESS "1200, 2400, 4800, 9600, and 19.2"
  473.     MESS " "
  474.     MESS "Speed (carriage rtn alone accepts): "
  475. ;
  476. ;    Wait for entry, and interpret
  477. ;
  478.     S0 = "    "             ; Default value
  479.     GET S0 4        ; Wait for a char
  480.     IF NULL S0 GOTO MOSPEND ; Nothing entered
  481.     IF NOT FIND "300  300120024004800960019.2" S0(0:2) N0 GOTO MOSPERR
  482.     IF 4*(N0/4) ne N0 GOTO MOSPERR
  483. ;
  484. ;    Save the value
  485. ;
  486.     S20(5:8) = S0        ; Set new value
  487.     GOSUB Save        ; Save the new value
  488. ;
  489. ;    End of window
  490. ;
  491. MOSPEND:
  492.     WCLOSE
  493.     RETURN
  494. ;
  495. ;    Error in input string
  496. ;
  497. MOSPERR:
  498.     SOUND 100,100        ; Bronx cheer
  499.     GOTO Modem_Speed    ; And try again
  500. ;
  501. ; ----- Subroutine: Modem_Control -> Set the modem initialization string to use
  502. ;
  503. Modem_Control:
  504.     WOPEN 0,0 23,79 (defa) Main_Esc
  505.     ATSAY 0,2 (defa)   " BBS Control "
  506.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  507.     LOCATE 2,2
  508.  
  509.     MESS "The BBS currently is set to initialize the modem with: "
  510.     S0 = S21        ; Fetch value
  511.     PRESERVE S0        ; Preserve for printing
  512.     MESS S0         ; Display string
  513.     MESS " "
  514.     MESS "The initialization string must be correct for your modem.  Please refer to "
  515.     MESS "the documentation that came with your modem.  The init string will probably"
  516.     MESS "begin with modem attention (defa 'AT'), MUST enable autoanswer, and will"
  517.     MESS "probably end with a carriage return.  "
  518.     MESS " "
  519.     MESS "Please note: Enter '^^A' through '^^Z' to indicate control chars, '^^^^ for'"
  520.     MESS "a single caret, '!!' for a carriage return (or '^^M') and '!!!!' for a single"
  521.     MESS "exclamation point."
  522.     MESS " "
  523.     MESS "Control string (carriage return accepts): "
  524. ;
  525. ;    Wait for entry, and interpret
  526. ;
  527.     S0 = "    "             ; Default value
  528.     GET S0 50        ; Wait for a char
  529.     IF NULL S0 GOTO MOCOEND ; Nothing entered
  530. ;
  531. ;    Save the value
  532. ;
  533.     S21 = S0        ; Set new value
  534.     GOSUB Save        ; Save the new value
  535. ;
  536. ;    End of window
  537. ;
  538. MOCOEND:
  539.     WCLOSE
  540.     RETURN
  541. ; -----------------------------------------------------------------------
  542. ; ----- Subroutine: CreateSd -> Create subdirectories
  543. ;    .. Flags 0-3 control
  544. ;
  545. CreateSd:
  546.     IF FLAG(0)        ; Main subd does not exist
  547.        S0 = S22        ; Set-up passed parm
  548.        GOSUB Create     ; Attempt to create it
  549.        GOSUB NewUser    ; Create needed file (if d.n.e)
  550.        ENDIF
  551.  
  552.     IF FLAG(1)        ; File subd does not exist
  553.        S0 = S23        ; Set-up passed parm
  554.        GOSUB Create     ; Attempt to create it
  555.        GOSUB NewFile    ; Create needed file (if d.n.e)
  556.        ENDIF
  557.  
  558.     IF FLAG(2)        ; Mail subd does not exist
  559.        S0 = S24        ; Set-up passed parm
  560.        GOSUB Create     ; Attempt to create it
  561.        GOSUB NewMail    ; Create needed file (if d.n.e)
  562.        ENDIF
  563.  
  564.     IF FLAG(3)        ; Bulletin subd does not exist
  565.        S0 = S25        ; Set-up passed parm
  566.        GOSUB Create     ; Attempt to create it
  567.        GOSUB NewBull    ; Create needed file (if d.n.e)
  568.        ENDIF
  569.     RETURN
  570. ;
  571. ; ----- Subroutine: CheckSd -> Create an subdirectories
  572. ;    .. Flags 0-3 control
  573. ;
  574. CheckSd:
  575.     FFIRST S0&"\*.*"        ; Test for existence of subdir
  576.     IF SUCCESS RETURN    ; Return if it exists
  577.     GOSUB Create        ; Attempt to create it
  578.     RETURN
  579. ;
  580. ; ----- Subroutine: Create -> Create a subdirectory
  581. ;    .. S0 passes the subdirectory to create
  582. ;
  583. Create:
  584.     MDIR S0         ; Attempt to create subdir
  585.     IF FAILURE        ; Set-up passed parm
  586.        S0 = "Error creating: "*S0
  587.        GOSUB Error        ; Report the error
  588.        SET SUCCESS OFF    ; Return FAILED condition
  589.        ENDIF
  590.     RETURN
  591. ;
  592. ; ----- Subroutine: NewUser -> Create a new BBS-User file
  593. ;
  594. NewUser:
  595.     IF ISFILE S22&"\BBS-User" RETURN
  596.     FOPENO S22&"\BBS-User" TEXT
  597.     IF NOT SUCCESS        ; Open failed
  598.        S0 = "Error creating: "*S22&"\BBS-User"
  599.        GOSUB Error        ; Report
  600.        RETURN        ; And we're done
  601.        ENDIF
  602.     WRITE "!^Z"             ; Make it empty
  603.     FCLOSEO         ; Done with it
  604.     RETURN
  605. ;
  606. ; ----- Subroutine: NewFile -> Create a new BBS-File file
  607. ;
  608. NewFile:
  609.     IF ISFILE S23&"\BBS-File" RETURN
  610.     FOPENO S23&"\BBS-File" TEXT
  611.     IF NOT SUCCESS        ; Open failed
  612.        S0 = "Error creating: "*S23&"\BBS-File"
  613.        GOSUB Error        ; Report
  614.        RETURN        ; And we're done
  615.        ENDIF
  616.     WRITE "!^Z"             ; Make it empty
  617.     FCLOSEO         ; Done with it
  618.     RETURN
  619. ;
  620. ; ----- Subroutine: NewMail -> Create a new BBS-Mail file
  621. ;
  622. NewMail:
  623.     IF ISFILE S24&"\BBS-Mail" RETURN
  624.     FOPENO S24&"\BBS-Mail" TEXT
  625.     IF NOT SUCCESS        ; Open failed
  626.        S0 = "Error creating: "*S24&"\BBS-Mail"
  627.        GOSUB Error        ; Report
  628.        RETURN        ; And we're done
  629.        ENDIF
  630.     WRITE "!^Z"             ; Make it empty
  631.     FCLOSEO         ; Done with it
  632.     RETURN
  633. ;
  634. ; ----- Subroutine: NewBull -> Create a new BBS-Bull file
  635. ;
  636. NewBull:
  637.     IF ISFILE S25&"\BBS-Bull" RETURN
  638.     FOPENO S25&"\BBS-Bull" TEXT
  639.     IF NOT SUCCESS        ; Open failed
  640.        S0 = "Error creating: "*S25&"\BBS-Bull"
  641.        GOSUB Error        ; Report
  642.        RETURN        ; And we're done
  643.        ENDIF
  644.     WRITE "!^Z"             ; Make it empty
  645.     FCLOSEO         ; Done with it
  646.     RETURN
  647. ; -----------------------------------------------------------------------
  648. ; ----- Subroutine: NewDat ->  Ask if a new BBSDAT file is to be placed?
  649. ;
  650. NewDat:
  651.     IF NULL S29 AND NOT ISSC "BBSDAT" RETURN
  652.     WOPEN 0,0 23,79 (defa) Main_ESC
  653.     ATSAY 0,2 (defa)   " BBS Subdirs "
  654.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  655. NEDA100:
  656.     CLEAR            ; Clear window
  657.     LOCATE 2,2
  658.     MESS "Do you wish to place BBSDAT on the new BBS main subdirectory? (y/n) "
  659.     MESS "──────────────────────────────────── "
  660.     MESS " "
  661.     IF NOT NULL S29
  662.        MESS "BBSDAT is currently: "*S29
  663.     ELSE
  664.        S0 = "_SUBD"&"\BBSDAT"
  665.        IF NOT ISFILE "BBSDAT"
  666.           ENVIRON S0 "COM-AND="; Look for COM-AND= environment var
  667.           IF FOUND        ; If environment variable found
  668.          LENGTH S0 N0    ; Get its length
  669.          N0 = N0-1    ; Point to last char in string
  670.          IF STRCMP S0(n0:n0) "\" S0(n0:n0) = ""
  671.          S0 = S0&"\BBSDAT"
  672.          ENDIF
  673.           ENDIF
  674.        IF ISFILE S0
  675.           MESS "BBSDAT is now: "*S0
  676.        ELSE
  677.           MESS "BBSDAT would be: "*S0
  678.           ENDIF
  679.        ENDIF
  680.     MESS "──────────────────────────────────── "
  681.     MESS " "
  682.     MESS "Enter y or n (carriage return = y): "
  683. ;
  684. ;    Wait for a keypress
  685. ;
  686.     GET S0 1        ; Wait for it
  687.     IF NULL S0 GOTO NEDA200 ; If c/r, simply accept
  688.     SWITCH S0        ; Act according to keyget
  689.       CASE "y"              ; Case insensitive
  690.            GOTO NEDA200
  691.            ENDCASE
  692.       CASE "n"              ; Case insensitive
  693.            WCLOSE        ; DO nothing
  694.            RETURN
  695.            ENDCASE
  696.       DEFAULT        ; None of the above
  697.            SOUND 100,100    ; Bronx cheer
  698.            ENDCASE
  699.       ENDSWITCH
  700.     GOTO NEDA100        ; Repaint screen and ask again
  701. ;
  702. ;    Construct the other subdir names
  703. ;
  704. NEDA200:
  705.     S29 = S22&"\BBSDAT"
  706.     WCLOSE
  707.     RETURN
  708. ; -----------------------------------------------------------------------
  709. ; ----- Subroutine: DftSds ->  Main subdir changed - default the others?
  710. ;
  711. DftSds:
  712.     WOPEN 0,0 23,79 (defa) Main_ESC
  713.     ATSAY 0,2 (defa)   " BBS Subdirs "
  714.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  715. DFSD100:
  716.     CLEAR            ; Clear window
  717.     LOCATE 2,2
  718.     MESS " Do you wish to use the new main subdir as the root for others? (y/n) "
  719.     MESS "──────────────────────────────────── "
  720.     MESS "    BBS main subdir is now:   "*S22
  721.     MESS "    Files subdir WOULD be:    "*S22&"\Files"
  722.     MESS "    Mail subdir WOULD be:     "*S22&"\Mail"
  723.     MESS "    Bulletin subdir WOULD be: "*S22&"\Bulletin"
  724.     MESS " "
  725.     MESS "──────────────────────────────────── "
  726.     MESS "Enter y or n (carriage return = y): "
  727. ;
  728. ;    Wait for a keypress
  729. ;
  730.     GET S0 1        ; Wait for it
  731.     IF NULL S0 GOTO DFSD200 ; If c/r, simply accept
  732.     SWITCH S0        ; Act according to keyget
  733.       CASE "y"              ; Case insensitive
  734.            GOTO DFSD200
  735.            ENDCASE
  736.       CASE "n"              ; Case insensitive
  737.            WCLOSE        ; DO nothing
  738.            RETURN
  739.            ENDCASE
  740.       DEFAULT        ; None of the above
  741.            SOUND 100,100    ; Bronx cheer
  742.            ENDCASE
  743.       ENDSWITCH
  744.     GOTO DFSD100        ; Repaint screen and ask again
  745. ;
  746. ;    Construct the other subdir names
  747. ;
  748. DFSD200:
  749.     S23 = S22&"\Files"
  750.     S24 = S22&"\Mail"
  751.     S25 = S22&"\Bulletin"
  752.     WCLOSE
  753.     RETURN
  754. ; -----------------------------------------------------------------------
  755. ; ----- Subroutine: Subdirs ->    Update subdirectories used by BBS
  756. ;
  757. Subdirs:
  758.     WOPEN 0,0 23,79 (defa) Main_Esc
  759.     ATSAY 0,2 (defa)   " BBS Subdirs "
  760.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  761. SUBD100:
  762.     CLEAR
  763.     LOCATE 2,2
  764.     MESS " 1) Identify BBS main subdir"
  765.     MESS " 2) Identify BBS Files subdir"
  766.     MESS " 3) Identify BBS Mail subdir"
  767.     MESS " 4) Identify BBS Bulletins subdir"
  768.  
  769.     MESS "──────────────────────────────────── "
  770.     MESS "    Main subdir     is: "*S22
  771.     MESS "    Files subdir    is: "*S23
  772.     MESS "    Mail subdir     is: "*S24
  773.     MESS "    Bulletin subdir is: "*S25
  774.     MESS " "
  775.     MESS "──────────────────────────────────── "
  776.     MESS "Select item (carriage return = previous): "
  777. ;
  778. ;    Wait for a keypress
  779. ;
  780.     GET S0 1        ; Wait for it
  781.     SWITCH S0        ; Act according to keyget
  782.       CASE "1"
  783.            GOSUB MainSd
  784.            ENDCASE
  785.       CASE "2"
  786.            GOSUB FileSd
  787.            ENDCASE
  788.       CASE "3"
  789.            GOSUB MailSd
  790.            ENDCASE
  791.       CASE "4"
  792.            GOSUB BullSd
  793.            ENDCASE
  794.       CASE "_NULL"          ; c/r alone is exit
  795.            WCLOSE        ; Close window...
  796.            RETURN        ; Leave Main routine
  797.            ENDCASE
  798.       DEFAULT        ; None of the above
  799.            SOUND 100,100    ; Bronx cheer
  800.            ENDCASE
  801.       ENDSWITCH
  802.     GOTO Subd100        ; Repaint screen and ask again
  803. ;
  804. ; ----- Subroutine: MainSd -> Set the main subdirectory
  805. ;
  806. MainSd:
  807.     WOPEN 0,0 23,79 (defa) Main_Esc
  808.     ATSAY 0,2 (defa)   " BBS Main Subdir "
  809.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  810.     LOCATE 2,2
  811.  
  812.     MESS "The BBS main subdirectory is: "
  813.     MESS S22
  814.     MESS " "
  815.     MESS "The main subdirectory must exist (it will be created if need be), and will "
  816.     MESS "contain at least one file (BBS-User).  The user ID file (BBS-User) residing"
  817.     MESS "there may be updated with from the main menu of this script."
  818.     MESS " "
  819.     MESS "BBS Main subdir (carriage return accepts): "
  820. ;
  821. ;    Wait for entry, and interpret
  822. ;
  823.     S0 = "    "             ; Default value
  824.     GET S0 50        ; Wait for a char
  825.     IF NULL S0 GOTO MASDEND ; Nothing entered
  826.     GOSUB CheckSd        ; Test for create needed
  827.     IF FAILED GOTO MASDEND    ; Skip if create failed
  828. ;
  829. ;    Save the value
  830. ;
  831.     S22 = S0        ; Set new value
  832.     GOSUB NewUser        ; Create needed file (if d.n.e)
  833.     GOSUB DftSds        ; Ask if we're to default the other subdirs
  834.     GOSUB NewDat        ; Ask if a new BBSDAT to be used
  835.     GOSUB Save        ; Save the new value
  836. ;
  837. ;    End of window
  838. ;
  839. MASDEND:
  840.     WCLOSE
  841.     RETURN
  842. ;
  843. ; ----- Subroutine: FileSd -> Set the file subdirectory
  844. ;
  845. FileSd:
  846.     WOPEN 0,0 23,79 (defa) Main_Esc
  847.     ATSAY 0,2 (defa)   " BBS File Subdir "
  848.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  849.     LOCATE 2,2
  850.  
  851.     MESS "The BBS file subdirectory is: "
  852.     MESS S23
  853.     MESS " "
  854.     MESS "The main subdirectory must exist (it will be created if need be), and will "
  855.     MESS "contain at least one file (BBS-File).  The file list (BBS-File) residing"
  856.     MESS "there may be updated with from the main menu of this script."
  857.     MESS " "
  858.     MESS "BBS File subdir (carriage return accepts): "
  859. ;
  860. ;    Wait for entry, and interpret
  861. ;
  862.     S0 = "    "             ; Default value
  863.     GET S0 50        ; Wait for a char
  864.     IF NULL S0 GOTO FISDEND ; Nothing entered
  865.     GOSUB CheckSd        ; Test for create needed
  866.     IF FAILED GOTO FISDEND    ; Skip if create failed
  867.     GOSUB NewFile        ; Create needed file (if d.n.e)
  868. ;
  869. ;    Save the value
  870. ;
  871.     S23 = S0        ; Set new value
  872.     GOSUB Save        ; Save the new value
  873. ;
  874. ;    End of window
  875. ;
  876. FISDEND:
  877.     WCLOSE
  878.     RETURN
  879. ;
  880. ; ----- Subroutine: MailSd -> Set the mail subdirectory
  881. ;
  882. MailSd:
  883.     WOPEN 0,0 23,79 (defa) Main_Esc
  884.     ATSAY 0,2 (defa)   " BBS Mail Subdir "
  885.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  886.     LOCATE 2,2
  887.  
  888.     MESS "The BBS Mail subdirectory is: "
  889.     MESS S24
  890.     MESS " "
  891.     MESS "The Mail subdirectory must exist (it will be created if need be), and will "
  892.     MESS "contain at least one file (BBS-Mail).  The user ID file (BBS-Mail) residing"
  893.     MESS "there may be updated with from the main menu of this script."
  894.     MESS " "
  895.     MESS "BBS Mail subdir (carriage return accepts): "
  896. ;
  897. ;    Wait for entry, and interpret
  898. ;
  899.     S0 = "    "             ; Default value
  900.     GET S0 50        ; Wait for a char
  901.     IF NULL S0 GOTO MLSDEND ; Nothing entered
  902.     GOSUB CheckSd        ; Test for create needed
  903.     IF FAILED GOTO MLSDEND    ; Skip if create failed
  904.     GOSUB NewMail        ; Create needed file (if d.n.e)
  905. ;
  906. ;    Save the value
  907. ;
  908.     S24 = S0        ; Set new value
  909.     GOSUB Save        ; Save the new value
  910. ;
  911. ;    End of window
  912. ;
  913. MLSDEND:
  914.     WCLOSE
  915.     RETURN
  916. ;
  917. ; ----- Subroutine: BullSd -> Set the bulletin subdirectory
  918. ;
  919. BullSd:
  920.     WOPEN 0,0 23,79 (defa) Main_Esc
  921.     ATSAY 0,2 (defa)   " BBS Bulletin Subdir "
  922.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  923.     LOCATE 2,2
  924.  
  925.     MESS "The BBS bulletin subdirectory is: "
  926.     MESS S25
  927.     MESS " "
  928.     MESS "The Bulletin subdirectory must exist (it will be created if need be), and will "
  929.     MESS "contain at least one file (BBS-Bull).  The user ID file (BBS-Bull) residing"
  930.     MESS "there may be updated with from the main menu of this script."
  931.     MESS " "
  932.     MESS "BBS Bulletin subdir (carriage return accepts): "
  933. ;
  934. ;    Wait for entry, and interpret
  935. ;
  936.     S0 = "    "             ; Default value
  937.     GET S0 50        ; Wait for a char
  938.     IF NULL S0 GOTO BUSDEND ; Nothing entered
  939.     GOSUB CheckSd        ; Test for create needed
  940.     IF FAILED GOTO BUSDEND    ; Skip if create failed
  941.     GOSUB NewBull        ; Create needed file (if d.n.e)
  942. ;
  943. ;    Save the value
  944. ;
  945.     S25 = S0        ; Set new value
  946.     GOSUB Save        ; Save the new value
  947. ;
  948. ;    End of window
  949. ;
  950. BUSDEND:
  951.     WCLOSE
  952.     RETURN
  953.